﻿
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace WpfExceptionWindow
{
    /// <summary>
    /// Provides extension methods for specific enumerations
    /// </summary>
    public static class EnumExtensions
    {
        //Code design from:
        //http://journal.stuffwithstuff.com/2008/03/05/checking-flags-in-c-enums/


        /// <summary>
        /// Determines whether the specified option is set.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="option">The flags.</param>
        /// <returns>
        /// 	<c>true</c> if the specified options is set; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsSet(this ExceptionWindowOptions options, ExceptionWindowOptions option)
        {
            return (options & option) == option;
        }

        /// <summary>
        /// Determines whether the specified option is not set.
        /// </summary>
        /// <param name="options">The <see cref="ExceptionWindowOptions"/> value.</param>
        /// <param name="option">The flags.</param>
        /// <returns>
        /// 	<c>true</c> if the specified options is not set; otherwise, <c>false</c>.
        /// </returns>
        public static bool IsNotSet(this ExceptionWindowOptions options, ExceptionWindowOptions option)
        {
            return (options & (~option)) == 0;
        }

        /// <summary>
        /// Sets the specified option.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="option">The flags.</param>
        /// <returns></returns>
        public static ExceptionWindowOptions Set(this ExceptionWindowOptions options, ExceptionWindowOptions option)
        {
            return options | option;
        }

        /// <summary>
        /// Unsets the specified option.
        /// </summary>
        /// <param name="options">The options.</param>
        /// <param name="option">The flags.</param>
        /// <returns></returns>
        public static ExceptionWindowOptions Unset(this ExceptionWindowOptions options, ExceptionWindowOptions option)
        {
            return options & option;
        }


        internal static bool IsPossibleResult(this ExceptionWindowButton button, ExceptionWindowResult result)
        {
            return button.ToString().Contains(result.ToString());
        }
    }
}
